#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#define F first
#define S second
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
ll a[2030][2030];
ll sum[2030][2030];
void solve()
{
	int n;
	cin>>n;
	int num=1;
	int cnt=1;
	while(num<n)
	{
		cnt++;
		num+=cnt;
//		cout<<num<<endl;
	}
	int r=cnt;
	int c=cnt-(cnt*(cnt+1)/2-n);

//	cout<<r<<endl<<c<<endl;
	ll ans=0;
	while(sum[r][c]!=0)
	{
		ans+=sum[r][c];
		r--;
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
}
int main()
{
	IOS;
	ll cnt=0;
	for(int i=1;i<=2023;i++)
	{
		for(int j=1;j<=i;j++)
		{
			cnt++;
			a[i][j]=cnt*cnt;
			sum[i][j]=sum[i-1][j-1]+a[i][j];
		}
	}
	
	int T=1;
	cin>>T;

	while(T--)
	{
		solve();
	}

	return 0;
}

